//
//  OrderEvaluationTableViewCell.m
//  PigMarket
//
//  Created by 张敬 on 2019/9/12.
//  Copyright © 2019年 pigmarket.oc. All rights reserved.
//

#import "OrderEvaluationTableViewCell.h"

@implementation OrderEvaluationTableViewCell

- (void)setupUI
{
    [self addSubview:self.shopIcon];
    [self addSubview:self.pigTypeTipLab];
    [self addSubview:self.pigTypeNOLab];
    [self addSubview:self.pigTypePriceLab];
    [self addSubview:self.evaluationLab];
    [self addSubview:self.thanksLab];

}


- (void)setupLayout
{
    {
        _shopIcon.size = CGSizeMake(56, 56);
        _shopIcon.mj_x = 15;
        _shopIcon.mj_y = 10;
    }
    
    
    {
        _pigTypeTipLab.frame = CGRectMake(0, 0, 200, 30);
        [_pigTypeTipLab sizeToFit];
        _pigTypeTipLab.width += 10;
        _pigTypeTipLab.height += 5;
        _pigTypeTipLab.mj_x = _shopIcon.right + 10;
        _pigTypeTipLab.mj_y = 12;
    }
    
    {
        _pigTypeNOLab.size = CGSizeMake(100, 21);
        _pigTypeNOLab.mj_x = _pigTypeTipLab.right + 5;
        _pigTypeNOLab.mj_y = _pigTypeTipLab.mj_y;
    }
    

    {
        _pigTypePriceLab.size = CGSizeMake(100, 17);
        _pigTypePriceLab.mj_x = _shopIcon.right + 12;
        _pigTypePriceLab.mj_y = _pigTypeTipLab.bottom + 8;
    }
    
    {
        _evaluationLab.size = CGSizeMake(76, 26);
        _evaluationLab.mj_x = KScreenWidth - _evaluationLab.width - 15;
        _evaluationLab.mj_y = 34;
    }
    
    {
        _thanksLab.size = CGSizeMake(200, 18);
        _thanksLab.mj_x = KScreenWidth - _thanksLab.width - 15;
        _thanksLab.mj_y = 34;
    }
}

#pragma mark - setter methods

- (void)setType:(OrderEvaluationType)type{
    
    if (type == OrderEvaluationType_Default) {
        _evaluationLab.hidden = NO;
        _thanksLab.hidden = YES;
    }else{
        _evaluationLab.hidden = YES;
        _thanksLab.hidden = NO;
    }
}


#pragma mark - getter methods

- (UIImageView *)shopIcon{
    if (!_shopIcon) {
        _shopIcon = [[UIImageView alloc] init];
        [self addShadowAndCircleCorner:_shopIcon.layer corner:5];
        _shopIcon.image = [UIImage imageNamed:@"placeholder_small"];
    }
    return _shopIcon;
}


- (UILabel *)pigTypeTipLab{
    
    if (! _pigTypeTipLab){
        _pigTypeTipLab = [UILabel makeLabelWithText:@"五花肉" textColor:mMainColor font:mFont(12) textAliment:1];
        _pigTypeTipLab.backgroundColor = UIColorFromRGB(0xE9F9F0);
        [self addShadowAndCircleCorner:_pigTypeTipLab.layer corner:3];
    }
    return _pigTypeTipLab;
}


- (UILabel *)pigTypeNOLab{
    
    if (!_pigTypeNOLab){
        _pigTypeNOLab = [UILabel makeLabelWithText:@"HT-02" textColor:UIColorFromRGB(0x333333) font:mFont(15) textAliment:0];
    }
    return _pigTypeNOLab;
}


- (UILabel *)pigTypePriceLab{
    
    if (!_pigTypePriceLab){
        _pigTypePriceLab = [UILabel makeLabelWithText:@"172.8" textColor:UIColorFromRGB(0x4D4D4D) font:mFont(12) textAliment:2];
    }
    return _pigTypePriceLab;
}

- (UILabel *)evaluationLab{
    
    if (!_evaluationLab){
        _evaluationLab = [UILabel makeLabelWithText:@"追评" textColor:mMainColor font:mFont(13) textAliment:1];
        _evaluationLab.layer.borderColor = mMainColor.CGColor;
        _evaluationLab.layer.borderWidth = 1.0;
        [self addShadowAndCircleCorner:_evaluationLab.layer corner:13];
        _evaluationLab.hidden = YES;
        
        @weakify(self);
        _evaluationLab.tapBlock = ^{
            @strongify(self);
            
            if (self.dealEvlationBlock) {
                self.dealEvlationBlock();
            }
        };
    }
    return _evaluationLab;
}

- (UILabel *)thanksLab{
    
    if (!_thanksLab){
        _thanksLab = [UILabel makeLabelWithText:@"感谢你的评价！" textColor:UIColorFromRGB(0x999999) font:mFont(13) textAliment:2];
        _thanksLab.hidden = YES;
    }
    return _thanksLab;
}

@end
